package com.cloudfast.platform.app.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.cloudfast.common.result.ApiResponse;
import com.cloudfast.controller.BaseController;
import com.cloudfast.platform.app.AppClient;
import com.cloudfast.platform.app.service.AppService;

/**
 * app 对接配置
 *
 * @author liuyw
 * @date 2022年9月11日
 */
@RestController
@RequestMapping(value = "app")
@Api(value = "APP管理", tags = "APP管理")
public class AppController extends BaseController<AppClient> {

    @Autowired
    private AppService appService;

    /**
     * 查询app密钥信息
     *
     * @param appLabel
     * @return
     */
    @PostMapping(value = "findOneByLabel")
    @ApiOperation("根据label查询app")
    public AppClient findOneByAppLabel(String appLabel, String corpId, String appType) {
        return appService.findOneByAppLabel(appLabel, corpId, appType);
    }

    /**
     * 判断 appLabel存在
     *
     * @param appLabel
     * @param id
     * @return
     */
    @PostMapping(value = "checkAppLabelExist")
    @ApiOperation("查询app label是否存在")
    public ApiResponse checkAppLabelExist(String appLabel, Long id) {
        return ApiResponse.success(appService.checkAppLabelExist(appLabel, id));
    }
}
